#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author  : micah
# @time    : 2023/9/4 21:44
# @function: 使用Python完成数据的增删改查
# @version :


import pymysql


# 通过函数的方式完成数据的增删改查
def db_connect():
    # 1.链接数据库，返回一个实例对象，链接对象
    db = pymysql.connect(host='localhost', user='root', password='123456', db='test')
    cursor = db.cursor()

    sql = """
        create table employee(
        first_name = varchar(20) not null,
        last_name = varchar(20),
        age int,
        sex varchar(1),
        income float,
        create_time datetime
        );
    """

    try:
        cursor.execute(sql)
        print("CREATE TABLE SUCCESS.")
    except Exception as ex:
        print(f"CREATE TABLE FAILED,CASE:{ex}")